{include file="public/header" /}
<style>
    #uploader .statusBar .progress{
        width:100px;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑小区</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">小区名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_name" lay-verify="required" placeholder="小区名称" class="layui-input" value="{$dis.dis_name}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">楼栋数：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_loudong" lay-verify="required" placeholder="楼栋数" class="layui-input" value="{$dis.dis_loudong}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">总面积(㎡)：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_mianji" lay-verify="required" placeholder="总面积(㎡)" class="layui-input" value="{$dis.dis_mianji}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">主图：</label>
                            <input type="hidden" name="del" id="del" value="">
                            <input type="hidden" id="hid" value="{$dis.dis_images}">
                            <input type="hidden" name="photo" id="photo" value="{$dis.dis_images}">
                            <div class="layui-input-block">
                                <div class="page-container">
                                    <div id="uploader" class="wu-example">
                                        <div class="queueList">
                                            <div id="dndArea" class="placeholder">
                                                <div id="filePicker"></div>
                                                <p>或将照片拖到这里,支持JPG,JPEG,PNG,BMP,GIF</p >
                                            </div>
                                        </div>
                                        <div class="statusBar" style="display:none;">
                                            <div class="progress progress-striped active">
                                                <div class="progress-bar progress-bar-success">
                                                    <span>0%</span>
                                                </div>
                                            </div>
                                            <div class="info"></div>
                                            <div class="btns">
                                                <div id="filePicker2"></div>
                                                <div class="uploadBtn">开始上传</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">户数(户)：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_house" lay-verify="required" placeholder="户数(户)" class="layui-input" value="{$dis.dis_house}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">停车位(个)：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_part" lay-verify="required" placeholder="停车位(个)" class="layui-input" value="{$dis.dis_part}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">容积率(%)：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_rongji" lay-verify="required" placeholder="容积率(%)" class="layui-input" value="{$dis.dis_rongji}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">物业费(元)：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_wuyefei" lay-verify="required" placeholder="物业费(元)" class="layui-input" value="{$dis.dis_wuyefei}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">绿化率(%)：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_lvhua" lay-verify="required" placeholder="绿化率(%)" class="layui-input" value="{$dis.dis_lvhua}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">开发商：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_kaifa" lay-verify="required" placeholder="开发商" class="layui-input" value="{$dis.dis_kaifa}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">物业公司：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_wuyecom" lay-verify="required" placeholder="物业公司" class="layui-input" value="{$dis.dis_wuyecom}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">均价(元/㎡)：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_price" lay-verify="required" placeholder="均价(元/㎡)" class="layui-input" value="{$dis.dis_price}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">描述：</label>
                            <div class="layui-input-block">
                                <textarea name="dis_desc" id="dis_desc" class="layui-input " style="height:80px">{$dis.dis_desc}</textarea>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">楼型：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_louxing" lay-verify="required" placeholder="楼型" class="layui-input" value="{$dis.dis_louxing}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">年代：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_year" lay-verify="required" placeholder="年代" class="layui-input" value="{$dis.dis_year}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">商圈：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_shangq" lay-verify="required" placeholder="商圈" class="layui-input" value="{$dis.dis_shangq}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">建筑面积：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_mendian" lay-verify="required" placeholder="建筑面积" class="layui-input" value="{$dis.dis_mendian}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">交通：</label>
                            <div class="layui-input-block">
                                <input type="text" name="dis_jiaot" lay-verify="required" placeholder="交通" class="layui-input" value="{$dis.dis_jiaot}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">省：</label>
                            <div class="layui-input-block">
                                <select name="dis_sheng" lay-search="" id="province"  lay-filter="province">
                                    <option value="">---- 请选择省 ----</option>
                                    {foreach name="province" item="v1"}
                                    <option value="{$v1.district_id}" {$dis.dis_sheng == $v1.district_id ? 'selected' : ''}>{$v1.district}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">市：</label>
                            <div class="layui-input-block">
                                <select name="dis_shi" lay-search=""  id="city"  lay-filter="city">
                                    {foreach name="city" item="v2"}
                                    <option value="{$v2.district_id}" {$dis.dis_shi == $v2.district_id ? 'selected' : ''}>{$v2.district}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">区：</label>
                            <div class="layui-input-block">
                                <select name="dis_qu" lay-search=""  id="district"  lay-filter="district">
                                    {foreach name="district" item="v3"}
                                    <option value="{$v3.district_id}" {$dis.dis_qu == $v3.district_id ? 'selected' : ''}>{$v3.district}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8" style="margin-top:50px">
                            <label class="layui-form-label">地址:</label>
                            <div class="layui-input-block">
                                <div id="container" style='width:90%;height:400px;z-index: 100;'></div>
                                <div id="myPageTop" style="margin-left: 150px;margin-top:10px;z-index:1000" >
                                    <table>
                                        <tr>
                                            <td>
                                                <label>请输入搜索内容</label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <input id="tipinput" class="dingwei" style="position: absolute;top: 0;right: -120px" placeholder="请输入地址"/>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">定位的地址:</label>
                            <div class="layui-input-block">
                                <table style="border-collapse:separate; border-spacing:5px;">
                                    <tr>
                                        <td>
                                            <input type="text" name="dis_address" class="dis_address" style="height:30px;width:500px" placeholder="详情地址" value="{$dis.dis_address}"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="text" readonly name="dis_lon" class="dis_lon" style="height:30px" placeholder="经度" value="{$dis.dis_lon}"/>
                                        </td>
                                        <td>
                                            <input type="text" readonly name="dis_lat" class="dis_lat" style="margin-left:-250px;height:30px" placeholder="纬度" value="{$dis.dis_lat}"/>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>

                        <input type="hidden" value="{$dis_id}" name="dis_id">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="__JS__/webupload/webuploader_update.js"></script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=3108d268226b46915b5faa028a004245&plugin=AMap.Autocomplete,AMap.PlaceSearch,AMap.Geocode"></script>
<script type="text/javascript">
    var map = new AMap.Map("container", {
        resizeEnable: true
    });
    var autoOptions = {
        input: "tipinput"
    };
    var auto = new AMap.Autocomplete(autoOptions);
    var placeSearch = new AMap.PlaceSearch({
        map: map
    });
    AMap.event.addListener(auto, "select", select);
    function select(e) {
        placeSearch.setCity(e.poi.adcode);
        placeSearch.search(e.poi.name);
        var lng = e.poi.location.lng;   //获取经度
        var lat = e.poi.location.lat;   //获取纬度
        var address = e.poi.district+e.poi.name;   //获取纬度
        $('input[name=dis_address]').val(address);
        $('input[name=dis_lon]').val(lng);
        $('input[name=dis_lat]').val(lat);
    }
    AMap.event.addListener(placeSearch, "markerClick", addasd);

    function addasd(e) {
        $('input[name=dis_address]').val(e.data.pname+e.data.cityname+e.data.adname+e.data.name);
        $('input[name=dis_lon]').val(e.data.location.lng);
        $('input[name=dis_lat]').val(e.data.location.lat);
    }
</script>
<script>
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('District/disEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('District/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>
</body>
</html>
